﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Role_Manage.aspx.cs" Inherits="Catering.Catering_Page.system.Role_Manage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Style/zhezhao.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <style type="text/css">
        *{margin:0px; padding:0px;}
        .search_title{background-color:#e5f1ff; border:1px solid #c2def6;margin-top:10px;}
        .main{margin-top:10px;}
        .table_title{ background:url(../../Images/table_th_bg.gif) repeat-x 0px 0px;height:32px;}
        .Page{width:300px;margin:10px auto 0px auto;}
        body{ font-size:12px;}
        li{ list-style-type:none;}
        .table_120 td{padding:5px 0px;}
        .main_left{width:100px;float:left; border:1px solid #c2def6; text-align:center;height:320px; overflow-y:auto;}
        .main_left h2{width:100px; background-color:#e5f1ff; font-size:14px; height:25px; line-height:25px; text-align:center;}
        .main_right{width:680px; float:left;border:1px solid #c2def6;height:320px; margin-left:10px;}
        .main_right_h2{width:670px; background-color:#e5f1ff; font-size:14px; height:25px; line-height:25px; text-align:left;padding-left:10px;}
        .right{width:670px;padding-left:10px; height:295px; overflow-y:scroll;}
        .right_h2{width:665px; font-size:14px; font-weight:600; text-align:left;margin-top:10px;}
        .kufang{width:645px;padding-left:10px; clear:both;}
        .gn_title{width:605px; font-size:13px; font-weight:600; text-align:left;hegiht:30px; line-height:30px;  clear:both;margin-top:10px;}
        .gn_list{width:605px;clear:both;padding-left:10px;}
        .gn_list li{ float:left; height:20px; line-height:20px;margin-left:10px; white-space:nowrap;}
        .gn_list li input{ vertical-align:middle;}
        .roletrees{ background-color:#FF9900; line-height:20px; height:20px; color:#ffffff; padding:0px 3px;}
        .roletree{line-height:20px; height:20px; padding:0px 3px;}
        .modulediv{width:98%; background-color:#ECF6FF; border:1px solid #AEC9F9; margin-top:10px; clear:both; padding-bottom:10px;}
        .modulet{height:30px; line-height:30px; border-bottom:1px solid #AEC9F9; width:100%; clear:both;}
        .modulet table td input{ vertical-align:middle;} 
        .modulets{color:#FF9900; font-size:14px; font-weight:bold;}
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            //单选
            $("input[name='ck_gn']").click(function () {
                if ($(this).is(":checked")) {
                    $("input[cid='" + $(this).attr("Pid") + "']").attr("checked", true);
                }
            });

            //全选、取消
            $("input[name='ck_Module']").click(function () {
                if ($(this).is(":checked")) {
                    $("input[Pid='" + $(this).attr("cid") + "']").attr("checked", true);
                }
                else {
                    $("input[Pid='" + $(this).attr("cid") + "']").attr("checked", false);
                }
            });
        });

        //保存权限
        function btn_Save() {
            var Rid = $("#HidRid").val();
            if (Rid == "") {
                alert("请选择角色节点！");
                return;
            }

            var stridlist = "";
            $("input").each(function () {
                if (this.checked) {
                    stridlist += $(this).val() + ",";
                }
            });

            if (stridlist == "")
                return;

            $.ajax({
                type: "Post",
                url: "Role_Manage.aspx/btn_Save",
                data: "{'Rid':'" + Rid + "','idlist':'" + stridlist + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d[0] = "OK") {
                        alert("保存成功！");
                        window.location = 'Role_Manage.aspx?Rid='+data.d[1];
                    }
                }
            });
        }

        //重置界面
        function btn_cz() {
            window.location = 'Role_Manage.aspx';
        }

        function checkRole() {
            var checkobj = $("#txt_name").val();
            if (checkobj == "") {
                alert("请输入角色名称！");
                return false;
            }

            checkobj = $("#txt_QuanZhong").val();
            if (checkobj == "") {
                alert("请输入权重！");
                return false;
            }
            if (isNaN(checkobj)) {
                alert("权重为1-10的数字！");
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidRid" runat="server" Value="" />
    <div class="layout">
        <div class="search_title">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="right" width="75">角色名称：</td>
                    <td width="100"><asp:TextBox ID="txt_name" runat="server" Width="90" CssClass="input_bg"></asp:TextBox></td>
                    <td align="right" width="75">角色描述：</td>
                    <td width="100"><asp:TextBox ID="txt_back" runat="server" Width="90" CssClass="input_bg"></asp:TextBox></td>
                    <td align="right" width="45">权重：</td>
                    <td width="40"><asp:TextBox ID="txt_QuanZhong" runat="server" Width="30" CssClass="input_bg"></asp:TextBox></td>
                    <td>&nbsp;</td>
                    <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "System_power.aspx", "角色管理操作"))
                      { %>
                    <td align="right" width="90"><input type="button" id="Button1" onclick="btn_cz()" class="input_btn_a" value="重置" /></td>
                    <td align="right" width="90"><asp:Button ID="btn_Add" runat="server" OnClientClick="return checkRole()" CssClass="input_btn_a" Text="添加角色" onclick="btn_Add_Click"/></td>
                    <td align="right" width="90"><asp:Button ID="btn_Edit" runat="server" OnClientClick="return checkRole()" CssClass="input_btn_a" Text="修改角色" onclick="btn_Edit_Click"/></td>
                    <td align="right" width="90"><input type="button" id="btn_Save1" onclick="btn_Save()" class="input_btn_a" value="保存权限" /></td>
                    <%} %>
                    <td align="right" width="10">&nbsp;</td>
                </tr>
            </table>
        </div>
        
        <div class="main">
            <div class="main_left">
                <h2>角色列表</h2><asp:TreeView ID="Tv_Role" runat="server" OnSelectedNodeChanged="Tv_Role_SelectedNodeChanged">
                    <NodeStyle CssClass="roletree" />
                    <SelectedNodeStyle CssClass="roletrees" />
                </asp:TreeView>
                
            </div>
            <div class="main_right">
                <h2 class="main_right_h2">权限模块</h2>                
                <div class="right">
                    <%=m_ModuleList%>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
